package com.igeek.boot.config;

import com.igeek.boot.job.CleanImgJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @package com.igeek.boot.config
 * @Description 定时任务配置类
 * @Author LittlePunk [296526219@qq.ccom]
 * @Version 2022.1
 * @Date 2024/1/8 23:05
 */
@Configuration
public class JobConfig {

    @Bean
    public JobDetail cleanImgJobDetail(){
        return JobBuilder.newJob(CleanImgJob.class).storeDurably().build();
    }

    //触发器
    @Bean
    public Trigger cleanImgTrigger(){
        //Cron调度器  0 0 2 * * ? 每天凌晨两点
        ScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/10 * * * * ? *");
        return TriggerBuilder.newTrigger().forJob(cleanImgJobDetail()).withSchedule(scheduleBuilder).build();
    }


}
